package com.aidex.system.controller;

import com.aidex.common.annotation.Log;
import com.aidex.common.core.controller.BaseController;
import com.aidex.common.core.domain.R;
import com.aidex.common.core.page.PageDomain;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import com.aidex.system.domain.WordMatchTime;
import com.aidex.system.service.WordMatchTimeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 大数据分词匹配次数Controller
 * @author jmy
 * @email jmyinjg@163.com
 * @date 2021-11-01
 */
@RestController
@RequestMapping("/system/wordMatchTime")
public class WordMatchTimeController extends BaseController
{
    @Autowired
    private WordMatchTimeService wordMatchTimeService;

    /**
     * 查询大数据分词匹配次数列表
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:list')")
    @GetMapping("/list")
    public R<PageInfo> list(WordMatchTime wordMatchTime, HttpServletRequest request, HttpServletResponse response)
    {
        wordMatchTime.setPage(new PageDomain(request, response));
        return R.data(wordMatchTimeService.findPage(wordMatchTime));
    }

    /**
     * 获取大数据分词匹配次数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:query')")
    @GetMapping(value = "/{id}")
    public R<WordMatchTime> detail(@PathVariable("id") String id)
    {
        return R.data(wordMatchTimeService.get(id));
    }

    /**
     * 新增大数据分词匹配次数
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:add')")
    @Log(title = "大数据分词匹配次数", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  WordMatchTime wordMatchTime)
    {
        return R.status(wordMatchTimeService.save(wordMatchTime));
    }

    /**
     * 修改大数据分词匹配次数
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:edit')")
    @Log(title = "大数据分词匹配次数", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated WordMatchTime wordMatchTime)
    {
        return R.status(wordMatchTimeService.save(wordMatchTime));
    }


    /**
     * 删除大数据分词匹配次数
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:remove')")
    @Log(title = "大数据分词匹配次数", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(wordMatchTimeService.deleteWordMatchTimeByIds(ids));
    }


    /**
     * 导出大数据分词匹配次数列表
     */
    @PreAuthorize("@ss.hasPermi('system:wordMatchTime:export')")
    @Log(title = "大数据分词匹配次数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(WordMatchTime wordMatchTime)
    {
        List<WordMatchTime> list = wordMatchTimeService.findList(wordMatchTime);
        ExcelUtil<WordMatchTime> util = new ExcelUtil<WordMatchTime>(WordMatchTime.class);
        return util.exportExcel(list, "wordMatchTime");
    }

}
